package ma.ac.onousc.gestionfi.budget.model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Set;

/**
 * The persistent class for the rubrique database table.
 * 
 */
@Entity
@NamedQueries({
		@NamedQuery(name = "Rubrique.findAll", query = "select o from Rubrique o"),
		@NamedQuery(name = "Rubrique.findByTypeBudget", query = "select o from Rubrique o join o.typeBudget t where o.typeBudget.idTypeBudget=:TYPE_BUDGET"),
		@NamedQuery(name = "Rubrique.findWithChildren", query = "select o from Rubrique o where exists (select a from Rubrique a where a.rubrique.idRubrique = o.idRubrique and a.typeBudget.idTypeBudget = :TYPE_BUDGET)") })
public class Rubrique implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID_RUBRIQUE")
	private int idRubrique;

	@Column(name = "CODE_RUBRIQUE")
	private int codeRubrique;

	@Column(name = "NOMENCLATURE_RUBRIQUE")
	private String nomenclatureRubrique;

	@Column(name = "VISIBLE_RUBRIQUE")
	private byte visibleRubrique;

	// bi-directional many-to-one association to Rubrique
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ID_RUBRIQUE_PARENTE")
	private Rubrique rubrique;

	// bi-directional many-to-one association to Rubrique
	@OneToMany(mappedBy = "rubrique",fetch = FetchType.EAGER)
	private Set<Rubrique> rubriques;

	// bi-directional many-to-one association to TypeBudget
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ID_TYPE_BUDGET")
	private TypeBudget typeBudget;

	// bi-directional many-to-one association to RubriqueBudgetaire
	@OneToMany(mappedBy = "rubrique")
	private Set<RubriqueBudgetaire> rubriqueBudgetaires;

	public Rubrique() {
	}

	public int getIdRubrique() {
		return this.idRubrique;
	}

	public void setIdRubrique(int idRubrique) {
		this.idRubrique = idRubrique;
	}

	public int getCodeRubrique() {
		return this.codeRubrique;
	}

	public void setCodeRubrique(int codeRubrique) {
		this.codeRubrique = codeRubrique;
	}

	public String getNomenclatureRubrique() {
		return this.nomenclatureRubrique;
	}

	public void setNomenclatureRubrique(String nomenclatureRubrique) {
		this.nomenclatureRubrique = nomenclatureRubrique;
	}

	public byte getVisibleRubrique() {
		return this.visibleRubrique;
	}

	public void setVisibleRubrique(byte visibleRubrique) {
		this.visibleRubrique = visibleRubrique;
	}

	public Rubrique getRubrique() {
		return this.rubrique;
	}

	public void setRubrique(Rubrique rubrique) {
		this.rubrique = rubrique;
	}

	public Set<Rubrique> getRubriques() {
		return this.rubriques;
	}

	public void setRubriques(Set<Rubrique> rubriques) {
		this.rubriques = rubriques;
	}

	public TypeBudget getTypeBudget() {
		return this.typeBudget;
	}

	public void setTypeBudget(TypeBudget typeBudget) {
		this.typeBudget = typeBudget;
	}

	public Set<RubriqueBudgetaire> getRubriqueBudgetaires() {
		return this.rubriqueBudgetaires;
	}

	public void setRubriqueBudgetaires(
			Set<RubriqueBudgetaire> rubriqueBudgetaires) {
		this.rubriqueBudgetaires = rubriqueBudgetaires;
	}

	@Override
	public String toString() {
		return this.codeRubrique + " " + this.nomenclatureRubrique;
	}
}